package com.example.mylibrary.testActivity.Adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.example.mylibrary.R;

import java.util.List;

public class testAdapter2 extends RecyclerView.Adapter<testAdapter2.MyViewHolder> {
    private Context context;
    private List<adapterBean> listData;
    public testAdapter2(Context context, List<adapterBean> listData) {
        this.context = context;
        this.listData = listData;
    }
    @NonNull
    @Override
    public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return  new MyViewHolder(LayoutInflater.from(context).inflate(R.layout.adapter_test,parent,false));
    }
    @Override
    public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
        holder.name.setText(listData.get(position).getName());
    }
    @Override
    public int getItemCount() {
        return listData ==null?0:listData.size();
    }
    class MyViewHolder extends RecyclerView.ViewHolder{
        TextView name;
        public MyViewHolder(View itemView) {
            super(itemView);
            name =  itemView.findViewById(R.id.textView3);
        }
    }

//    adapter = new testAdapter2(context,getList());
//    LinearLayoutManager mg = new LinearLayoutManager(context);
//        mg.setOrientation(LinearLayoutManager.VERTICAL);
//        recyclerView.setLayoutManager(mg);
//        recyclerView.setAdapter(adapter);

}
